import pandas as pd
pd.set_option('display.unicode.east_asian_width',True)
df=pd.read_excel('互联网广告智能投放数据.xlsx')
df['投放时间']=pd.to_datetime(df['投放时间']).dt.hour

df1=pd.crosstab(index=df['渠道'],columns=df['性别'],margins_name='比例',margins=True,normalize=True)
df1=pd.crosstab(index=df['渠道'],margins_name='比例',margins=True,normalize=True)
print('渠道和是否点击的交叉表:\n',df1)
